<%@page import="org.beanstech.persistence.Tblbook"%>
<%@page import="org.beanstech.persistence.Tbluser"%>
<%@page import="javax.persistence.criteria.CriteriaBuilder.In"%>
<%@page import="org.beanstech.dao.ObjectsByIds"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
	if(session.getAttribute("userid")==null){
	%>
	<jsp:forward page="Before_login.jsp"></jsp:forward>
	<%} %>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
	
	<link rel="stylesheet" href="css/main.css" type="text/css" />
	<script type="text/javascript">
	
	
	function doSubmit(){
		alert("Sending ......");
		$.ajax({
			url: 'SendContact',
			type: 'POST',
			data: $('#sendContact').serialize(),
			success: function(msg){
				$('#contact').replaceWith('<br/><button onclick="event.preventDefault(); parent.$.fancybox.close();">CLOSE</button>');
				
			}
			
		});
		
	}
	</script>
	<title>Second Book Exchange | Effort towards Green Campaign</title>
	<%
		ObjectsByIds getID = new ObjectsByIds();
		int contactto = Integer.parseInt(request.getParameter("userid"));
		int bookref = Integer.parseInt(request.getParameter("bookid"));
		Tbluser contactuser = getID.getUser(contactto);
		Tblbook book = getID.getBook(bookref);
	%>
</head>
<body>
<br/>
<h2>secondbook Exchange</h2> 

<div id="contact">
	<form id="sendContact" action="SendContact" method="post">
	<input type="hidden" name="messageto" value="<%=contactto%>">
	<input type="hidden" name="bookref" value="<%=bookref%>">
	
	<table width=300px; cellpadding="5px" cellspacing="4px">
		
		<tr>
			<td>Send to :<%=contactuser.getFname() %>&nbsp;<%=contactuser.getLname() %></td>
			
		</tr>
		<tr>
			<td>Book: <%=book.getBookname() %></td>
		</tr>
		<tr>
			<td><textarea rows="5" cols="40px" id="area1" name="message" style="font-family: verdana;"></textarea> </td>
		</tr>
		<tr>
			<td>Send By: <%=getID.getUser((Integer)session.getAttribute("userid")).getFname() %> <%=getID.getUser((Integer)session.getAttribute("userid")).getLname() %></td>
		</tr>
		<tr>
			<td>
				<input type="checkbox" name="mail" checked="checked"> Send Mail
				 <input type="checkbox" name="sms" > Send SMS
			</td>
		</tr>
		<tr>
			<td><a href="javascript:void(0)" onclick="javascript:doSubmit()"><img alt="submit" src="images/jpg_btn_submit_1.jpg"> </a></td>
		</tr>
	</table>
	</form>
</div>
</body>
</html>